package me.zk.practice1.hw;

import java.util.*;

/**
 * @author zhangkai
 * @date 2023/8/8 16:19
 */
public class HWBJ16 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String s = scanner.nextLine();

        Map<Character,Integer> map = new LinkedHashMap<>();

        StringBuffer sb = new StringBuffer();
        s = s.toLowerCase();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (Character.isLetter(c)) {
                sb.append(c);
                map.put(c,map.getOrDefault(c,0)+1);
            }
        }
        List<Letter> list = new ArrayList<>();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            int j = 1;
            int index = i+1;
            while (index < s.length()) {
                if(c==s.charAt(index)) {
                    index++;
                    j++;
                } else {
                    break;
                }
            }
            int all = map.get(c);
            if (j == 1) {
                list.add(new Letter(c,all-j));
            } else {
                list.add(new Letter(c,j));
                i = index-1;
            }
            map.put(c,all-j);

        }

        list.sort((a,b) -> {
            if(a.total == b.total){
                return a.name - b.name;
            }
            return b.total - a.total;
        });

        String res = "";
        for(Letter letter : list){
            res += String.valueOf(letter.name) + letter.total;
        }

        System.out.println(res);
    }

    static class Letter{

        char name;
        int total;

        public Letter(char name, int total){
            this.name = name;
            this.total = total;
        }

    }
}
